<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <home></home>
    
  </div>


  <script src="./vue.js"></script>
  <script>
    const Child = {
      template: `
        <div>
          <h3>我是子组件</h3>
          {{a}}
          {{b}}
          {{c}}
          {{d}}
          <button v-for="item in e" :key="item">
            {{ item }}  
          </button>
        </div>
      `,
      // props验证props 变成对象 key是待接收 属性列表，value是类型验证规则
      props: {
        a: Number,
        b: [Number, String],
        c: {
          type: String,
          required: true
        },
        d: {
          type: Number,
          default: 10
        },
        e: {
          type: Array,
          default: ()=> [1,2,3]
        }
      }
      
    }
    const Home = {
      template: `
        <div>
          <h2>我是父组件1</h2>
          <child :a="10" :b="30" c="字符串"></child>
        </div>
      `,
      data(){
        return {
          msg: '我是父组件中定义的动态数据'
        }
      },
      components: {
        Child
      }
    }
    Vue.component('Home', Home);
  
    const vm = new Vue({
      el: '#app',
      data: {

      }
    })
  </script>
</body>

</html>